package com.wiscofile.util;

import java.sql.*;

public class DBAssistant {
  public DBAssistant() {
  }

  public static void closeRS(ResultSet rs) {
    if (rs != null) {
      try {
        rs.close();
        rs = null;
      }
      catch (Exception e) {

      }
    }
  }

  public static void closeStatement(Statement pre) {
    if (pre != null) {
      try {
        pre.close();
        pre = null;
      }
      catch (Exception e) {

      }
    }
  }
  public static void closeConn(Connection conn, boolean commit) {
      if (conn != null) {
        try {
          conn.setAutoCommit(true);
          conn.close();
          conn = null;
        }
        catch (Exception e) {
          System.out.println(
              "Debug DBAssistant.closeConn(conn,commit) Exception : " +
              e.getMessage());
        }
      }
  }
  public static void closeConn(Connection conn) {
    if (conn != null) {
      try {
        conn.close();
        conn = null;
      }
      catch (Exception e) {

      }
    }
  }

  public static void closeConn2(Connection conn) {
      if (conn != null) {
          try {
              conn.rollback();
              conn.close();
              conn = null;
          } catch (Exception e) {

          }
      }
  }


  public static void closeRSC(ResultSet rs, Statement pre, Connection conn){
    closeRS(rs);
    closeStatement(pre);
    closeConn(conn);
  }

}

